﻿using System;
using System.Globalization;

namespace GeoAPI.CoordinateSystems
{
	[Serializable]
	public class Wgs84ConversionInfo : IEquatable<Wgs84ConversionInfo>
	{
		public Wgs84ConversionInfo() : this(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, string.Empty)
		{
		}

		public Wgs84ConversionInfo(double dx, double dy, double dz, double ex, double ey, double ez, double ppm) : this(dx, dy, dz, ex, ey, ez, ppm, string.Empty)
		{
		}

		public Wgs84ConversionInfo(double dx, double dy, double dz, double ex, double ey, double ez, double ppm, string areaOfUse)
		{
			this.Dx = dx;
			this.Dy = dy;
			this.Dz = dz;
			this.Ex = ex;
			this.Ey = ey;
			this.Ez = ez;
			this.Ppm = ppm;
			this.AreaOfUse = areaOfUse;
		}

		public double[] GetAffineTransform()
		{
			double num = 1.0 + this.Ppm * 1E-06;
			return new double[]
			{
				num,
				this.Ex * 4.84813681109536E-06 * num,
				this.Ey * 4.84813681109536E-06 * num,
				this.Ez * 4.84813681109536E-06 * num,
				this.Dx,
				this.Dy,
				this.Dz
			};
		}

		public string WKT
		{
			get
			{
				return string.Format(CultureInfo.InvariantCulture.NumberFormat, "TOWGS84[{0}, {1}, {2}, {3}, {4}, {5}, {6}]", new object[]
				{
					this.Dx,
					this.Dy,
					this.Dz,
					this.Ex,
					this.Ey,
					this.Ez,
					this.Ppm
				});
			}
		}

		public string XML
		{
			get
			{
				return string.Format(CultureInfo.InvariantCulture.NumberFormat, "<CS_WGS84ConversionInfo Dx=\"{0}\" Dy=\"{1}\" Dz=\"{2}\" Ex=\"{3}\" Ey=\"{4}\" Ez=\"{5}\" Ppm=\"{6}\" />", new object[]
				{
					this.Dx,
					this.Dy,
					this.Dz,
					this.Ex,
					this.Ey,
					this.Ez,
					this.Ppm
				});
			}
		}

		public override string ToString()
		{
			return this.WKT;
		}

		public bool HasZeroValuesOnly
		{
			get
			{
				return this.Dx == 0.0 && this.Dy == 0.0 && this.Dz == 0.0 && this.Ex == 0.0 && this.Ey == 0.0 && this.Ez == 0.0 && this.Ppm == 0.0;
			}
		}

		public override bool Equals(object obj)
		{
			return this.Equals(obj as Wgs84ConversionInfo);
		}

		public override int GetHashCode()
		{
			return this.Dx.GetHashCode() ^ this.Dy.GetHashCode() ^ this.Dz.GetHashCode() ^ this.Ex.GetHashCode() ^ this.Ey.GetHashCode() ^ this.Ez.GetHashCode() ^ this.Ppm.GetHashCode();
		}

		public bool Equals(Wgs84ConversionInfo obj)
		{
			return obj != null && (obj.Dx == this.Dx && obj.Dy == this.Dy && obj.Dz == this.Dz && obj.Ex == this.Ex && obj.Ey == this.Ey && obj.Ez == this.Ez) && obj.Ppm == this.Ppm;
		}

		private const double SEC_TO_RAD = 4.84813681109536E-06;

		public double Dx;

		public double Dy;

		public double Dz;

		public double Ex;

		public double Ey;

		public double Ez;

		public double Ppm;

		public string AreaOfUse;
	}
}
